package org.selenium;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/**
 * @Author: fzykd
 * Date: 2024/5/7
 * Time: 21:07
 * User: LQH
 */
public class Operation {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", "E:/software/Java/bin/chromedriver.exe");

        //谷歌驱动创建
        ChromeOptions options = new ChromeOptions();
        //这个也不能少 允许所有请求访问
        options.addArguments("--remote-allow-origins=*");
        WebDriver driver = new ChromeDriver(options);

        driver.get("https://www.baidu.com");

        Thread.sleep(1000);

        //打印信息
        String title = driver.getTitle();
        System.out.println("获取当前页面Title:" + title);

        Thread.sleep(1000);

        String currentUrl = driver.getCurrentUrl();
        Thread.sleep(1000);
        System.out.println("获取当前页面的URL: " + currentUrl);



        driver.quit();
    }
}
